{% extends "user_profile/user.html" %}
{% import "macros.html" as macros %}
<!-- user_email_subscriptions.html -->
{% block profilesection %}
    {% trans %}subscriptions{% endtrans %}
{% endblock %}
{% block usercontent %}
    <div id="email-subscriptions"> 
    <h2 style="font-size: 1.2em">{% trans %}Email subscription settings{% endtrans %}</h2>
    <p class="message" style="margin-top: 0.5em">
{% trans %}<span class='big strong'>Adjust frequency of email updates.</span> Receive updates on interesting content by email. If you do not wish to receive emails - select 'no email' on all items below.<br/>Updates are only sent when there is any new activity on selected items.{% endtrans %}</p>
    <div style="margin-top: 1em">
    {% if action_status %}
        <p class="action-status"><span>{{action_status}}</span></p>
    {% endif %}
    <form method="post" action="">{% csrf_token %}
        <table class='form-as-table ab-subscr-form'>
        {{email_feeds_form.as_table()}}
        </table>
        <table class='form-as-table ab-tag-filter-form'>
        {{tag_filter_selection_form}}
        </table>
        <div class="submit-row">
            <input class="normal-btn" type="submit" name="save" value="{% trans %}Update{% endtrans %}"/>&nbsp;
            <input class="normal-btn" type="submit" name="stop_email" value="{% trans %}Stop Email{% endtrans %}"/>
        </div>
    </form>
    </div>
    {% if settings.MULTILINGUAL %}
    <h2>{% trans %}Subscribed languages{% endtrans %}</h2>
    <form
        method="post" 
        action="{% url user_select_languages view_user.id, view_user.username|slugify %}"
    >{% csrf_token %}
        <select multiple name="languages">
        {% for lang in settings.LANGUAGES_DICT %}
            <option 
                value="{{ lang }}"
                {% if lang in user_languages %}selected="selected"{% endif %}
            >{{ settings.LANGUAGES_DICT[lang] }}</option>
        {% endfor %}
        </select><br/>
        <input type="submit" class="select-language" value="{% trans %}Save languages{% endtrans %}" />
    </form>
    {% endif %}

    {%if settings.SUBSCRIBED_TAG_SELECTOR_ENABLED %}
        <h2>{% trans %}Subscribed Tags{% endtrans %}</h2>
            {{
                macros.tag_list_widget(
                    subscribed_tag_names,
                    deletable = True,
                    css_class = 'subscribed marked-tags special',
                )
            }}
            <div class="clearfix"></div>
            <div class="inputs">
                <input id="subscribedTagInput" autocomplete="off" type="text"/>
                <input id="subscribedTagAdd" type="submit" value="{% trans %}add{% endtrans%}"/>
            </div>
        </div>
    {%endif%}
    </div>
{% endblock %}
{% block sidebar %}{% endblock %}
{% block userjs %}
    <script type='text/javascript'>
        search = new FullTextSearch();
        askbot['controllers'] = askbot['controllers'] || {}
        askbot['controllers']['fullTextSearch'] = search;
        askbot['urls']['mark_subscribed_tag'] = '{% url mark_subscribed_tag %}';
        askbot['urls']['unmark_tag'] = '{% url unmark_tag %}';
        askbot['settings']['tag_editor'] = '{{ tag_editor_settings|escapejs }}';
    </script>
    <script type='text/javascript' src='{{"/js/tag_selector.js"|media}}'></script>
{% endblock %}
<!-- end user_email_subscriptions.html -->
